from wordcloud import WordCloud
import matplotlib.pyplot as plt
from PIL import Image
import numpy as np

if __name__ == '__main__':
    text = "我 在 陕西 交通 职业 技术 学院 软件 技术 专业 学习，软件 专业 的 课程 很 有趣！"

    alice_mask = np.array(Image.open("./alice_mask.png"))

    # wc = WordCloud(font_path="./fonts/msyh.ttc")
    # wc = WordCloud(background_color="#ffffff", font_path="./fonts/msyh.ttc")
    # wc = WordCloud(width=800,height=600, font_path="./fonts/msyh.ttc")
    # wc = WordCloud(margin=20, font_path="./fonts/msyh.ttc")
    # wc = WordCloud(scale=4, font_path="./fonts/msyh.ttc")
    # wc = WordCloud(prefer_horizontal=1, font_path="./fonts/msyh.ttc")
    # wc = WordCloud(min_font_size=24,max_font_size=144, font_path="./fonts/msyh.ttc")
    # wc = WordCloud(font_step=24, font_path="./fonts/msyh.ttc")
    # wc = WordCloud(stopwords=["技术"], font_path="./fonts/msyh.ttc")
    wc = WordCloud(background_color="white", max_words=2000, mask=alice_mask,
                   contour_width=3, contour_color='steelblue', font_path="./fonts/msyh.ttc")
    wc.generate(text=text)

    plt.imshow(wc)
    plt.axis("off")
    plt.show()

    # wc.to_file("simple_scale.jpeg")

